package com.smzd.framework.oauth2.business;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smzd.core.dao.IDao;
import com.smzd.framework.core.business.AbstractFGService;
import com.smzd.framework.oauth2.dao.ResourceDao;
import com.smzd.framework.oauth2.domain.Resource;
import com.smzd.framework.utils.db.FGRowConverter;

@Service
public class ResourceService extends AbstractFGService<Resource> {
	@Autowired
	private ResourceDao dao;

	@Override
	protected IDao<Resource> getDao() {
		return dao;
	}

	@Override
	public FGRowConverter<Resource> getConverter() {
		return ResourceService.converter;
	}

	private static FGRowConverter<Resource> converter = new FGRowConverter<Resource>() {
		@Override
		public Object[] convert(Resource elem) {
			Object[] fields = new Object[] { 
					elem.getId(), 
					elem.getName(),
					elem.getResourceId(),
					elem.getDescription()
			};
			return fields;
		}
	};
	public List<Resource> getResourcesByClientAppId(int clientAppId){
		return dao.getResourcesByClientAppId(clientAppId);
	}
}
